home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 8206 / 8206.xpi / content / webmail / yahoo.js < prev    next >
Text File  |  2010-02-02  |  4KB  |  177 lines

  1. //WiseStampLog("[yahoo.js] >>>>>");
  2. window.addEventListener("load",function(event){yahoosig.pageload(event)},true);
  3. window.addEventListener("unload",function(event){yahoosig.uninitView(event)},true);
  4.  
  5. var yahoosig =
  6. {
  7.     current: null,
  8.     needToInsertButton: true,
  9.     pageload: function (event)
  10.     {
  11.         try
  12.         {
  13.             wisestampsig.refreshCallback = yahoosig.refreshSignature;
  14.             setTimeout(function ()
  15.             {
  16.                 yahoosig.setupCompose();
  17.             },
  18.             0);
  19.         } catch(e)
  20.         {
  21.             WiseStampLog(e);
  22.         }
  23.     },
  24.     uninitView: function ()
  25.     {
  26.         if (this.current && this["uninit" + this.current])
  27.         {
  28.             this["uninit" + this.current]();
  29.         }
  30.     },
  31.     setupCompose: function ()
  32.     {
  33.         var composeDiv = document.getElementById("tabMessageComposerBody");
  34.         var tcDiv = document.getElementById("tcDiv");
  35.         if (tcDiv || true)
  36.         {
  37.             try
  38.             {
  39.                 document.addEventListener("DOMNodeInserted", yahoosig.composeInserted, false);
  40.                 yahoosig.addWisestampIcon();
  41.                 yahoosig.findIframesAndInsert();
  42.             } catch(e)
  43.             {
  44.                 WiseStampLog(e);
  45.             }
  46.         }
  47.     },
  48.     findIframesAndInsert: function ()
  49.     {
  50.         var iframes = evaluateXPath(document, "//iframe[contains(@id,compArea_test_)]");
  51.         //WiseStampLog("iframes:  len: "+iframes.length);
  52.         if (iframes && iframes.length > 0)
  53.         {
  54.             //WiseStampLog("found iframes");
  55.             for (var i = 0; i < iframes.length; i++)
  56.             {
  57.                 try
  58.                 {
  59.                     //WiseStampLog("i: "+i+" "+iframes[i].id);
  60.                     if (/compArea_test_/.test(iframes[i].id))
  61.                     {
  62.                         //WiseStampLog(iframes[i].id);
  63.                         yahoosig.insertSignature(iframes[i]);
  64.                     }
  65.                 } catch(e)
  66.                 {
  67.                     WiseStampLog("exception caught: " + e);
  68.                 }
  69.             }
  70.         }
  71.     },
  72.     composeInserted: function (event)
  73.     {
  74.         //WiseStampLog("[yahoo.js::composeInserted] >>>>>");
  75.         var match = null;
  76.         if (event.target && event.target.id)
  77.         {
  78.             //WiseStampLog("composeInserted: "+event.target.id);
  79.             if (event.target.id == "richedittoolbar")
  80.             {
  81.                 setTimeout(function ()
  82.                 {
  83.                     yahoosig.addWisestampIcon(event.target);
  84.                 },
  85.                 0);
  86.             } else if ((match = event.target.id.match(/compArea_test_(.*)/)))
  87.             {
  88.                 if (yahoosig.needToInsertButton)
  89.                 {
  90.                     setTimeout(function ()
  91.                     {
  92.                         yahoosig.addWisestampIcon();
  93.                     },
  94.                     1000);
  95.                 }
  96.                 yahoosig.insertSignature(event.target);
  97.             } else if ((match = event.target.id.match(/tabCompose(.*)/)))
  98.             {
  99.                 setTimeout(function ()
  100.                 {
  101.                     yahoosig.addWisestampIcon();
  102.                     yahoosig.findIframesAndInsert();
  103.                 },
  104.                 1000);
  105.             }
  106.         }
  107.     },
  108.     addWisestampIcon: function ()
  109.     {
  110.         //WiseStampLog("[yahoo.js::addWisestampIcon] >>>>>");
  111.         if (wisestampsig.showButton)
  112.         {
  113.             var richtoolbars = document.getElementsByTagName("div");
  114.             if (richtoolbars && richtoolbars.length > 0)
  115.             {
  116.                 for (var i = 0; i < richtoolbars.length; i++)
  117.                 {
  118.                     var cont = richtoolbars[i];
  119.                     if (/richedittoolbar/.test(cont.id))
  120.                     {
  121.                         var before = cont.lastChild;
  122.                         var span = document.createElement("span");
  123.                         span.setAttribute("id", "wisestampIcon");
  124.                         span.setAttribute("class", "menuButton colorKTransparent");
  125.                         var div = document.createElement("div");
  126.                         div.setAttribute("unselectable", "on");
  127.                         div.setAttribute("class", "button");
  128.                         div.setAttribute("style", "background-image: url('" + wisestampsig.icon + "') !important; background-position: 4px 4px");
  129.                         span.appendChild(div);
  130.  
  131.                         var inserted = cont.insertBefore(span, cont.lastChild.previousSibling); //.appendChild(table);
  132.                         wisestampsig.initOptionsIcon(span);
  133.                         this.needToInsertButton = false;
  134.  
  135.                     }
  136.                 }
  137.             }
  138.         }
  139.         else this.needToInsertButton = false
  140.     },
  141.  
  142.     uninitCompose: function ()
  143.     {},
  144.  
  145.     iframeTries: 1,
  146.     refreshSignature: function ()
  147.     {
  148.         wisestampsig.insertSignature(yahoosig.iframe, false);
  149.     },
  150.     insertSignature: function (iframe)
  151.     {
  152.         //WiseStampLog("[yahoo.js::insertSignature] >>>>>");
  153.         this.iframe = iframe;
  154.         wisestampsig.insertSignature(yahoosig.iframe, true);
  155.         this.iframe.addEventListener('load', yahoosig.iframeLoad, false);
  156.         this.iframeLoad(false);
  157.     },
  158.     iframeLoad: function (event)
  159.     {
  160.         //WiseStampLog("iframeLoad: "+event);
  161.         var time = 500;
  162.         setTimeout(function ()
  163.         {
  164.             //WiseStampLog("iframeloadtimeout\n");
  165.             wisestampsig.insertSignature(yahoosig.iframe, true);
  166.             if (event)
  167.             {
  168.                 try
  169.                 {
  170.                     yahoosig.iframe.removeEventListener('load', yahoosig.iframeLoad, false);
  171.                 } catch(e)
  172.                 {}
  173.             }
  174.         },
  175.         time);
  176.     }
  177. };